import Lib from "../core/lib.js"
import config from '../config/config.js'
import {
	timestampToTime
} from '../core/utit.js'
const lib = new Lib();
const HttpModule = function() {
	//上传
	this.uploadFile = async function(data, showLoading) {
		console.log(data, 'data')
		return await lib.$upload({
			url: `${config.baseUrl}/wx/yulaw/file/upload`,
			data,
			responseCatch: (res, code, msg) => {
				return res
			}
		}, showLoading)
	};
	this.getYuBanner = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuBanner/${config.appid}/getYuBanner`,
			data: data,
			responseCatch: (res, code, msg) => {
				return res
			}
		}, showLoading)
	};
	this.getYuHandleTypeInfo = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuHandleType/${config.appid}/getYuHandleTypeInfo`,
			data: data,
			responseCatch: (res, code, msg) => {
				return res
			}
		}, showLoading)
	};

	this.findYuUserNoticByPage = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuUserNotic/${config.appid}/findYuUserNoticByPage`,
			data,
			responseCatch: (res, code, msg) => {
				if (res.data.data.length != 0) {
					res.data.data.forEach(item => {
						item.createTime = timestampToTime(item.createTime)
					})
				}
				return res.data.data
			}
		}, showLoading)
	}
	//新闻
	this.findYuNewsByPage = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuNews/${config.appid}/findYuNewsByPage`,
			data,
			responseCatch: (res, code, msg) => {
				if (res.data.data.length != 0) {
					res.data.data.forEach(item => {
						item.createTime = timestampToTime(item.createTime)
					})
				}
				return res.data.data
			}
		}, showLoading)
	}
	//帖子详情
	this.getDetails = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuUserNotic/${config.appid}/getDetails?id=` + data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//委托详情
	this.getDetailsTow = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuHandle/${config.appid}/lawyerFollow?id=` + data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//回帖
	this.addDetails = async function(data, showLoading) {
		return await lib.$post({
			url: `${config.baseUrl}/wx/yulaw/yuUserNotic/${config.appid}/addYuUserNotic`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data
			}
		}, showLoading)
	};
	//设置手机号
	this.getPhone = async function(data, showLoading) {
		return await lib.$get({
			// ${config.baseUrl}/wx/yulaw/user/wxf60bdde4472ae369/info
			url: `${config.baseUrl}/wx/yulaw/user/${config.appid}/phone`,
			data,
			responseCatch: (res, code, msg) => {
				return res
			}
		}, showLoading)
	};
	//帖子回复
	this.addYuUserNotic = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuUserNotic/${config.appid}/addYuUserNotic?id=` + data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//擅长领域
	this.getFieldList = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuSysDict/${config.appid}/findSysCase`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//发布委托
	this.addYuHandle = async function(data, showLoading) {
		return await lib.$post({
			url: `${config.baseUrl}/wx/yulaw/yuHandle/${config.appid}/addYuHandle`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//委托列表
	this.findYuHandleByPage = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuHandle/${config.appid}/findYuHandleByPage`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//律师列表
	this.findYuLawyerByPage = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuLawyer/${config.appid}/findYuLawyerByPage`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//成为律师
	this.useridByLawyer2 = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuLawyer/${config.appid}/useridByLawyer?userid=`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//律师录入的个人信息
	this.addYuLawyer = async function(data, showLoading) {
		return await lib.$post({
			url: `${config.baseUrl}/wx/yulaw/yuLawyer/${config.appid}//addYuLawyer`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//律师录入的个人信息
	this.editYuEntrust = async function(data, showLoading) {
		return await lib.$post({
			url: `${config.baseUrl}/wx/yulaw/yuEntrust/${config.appid}/editYuEntrust`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//律师录入的个人信息
	this.useridByLawyer = async function(data, showLoading) {
		return await lib.$get({

			url: `${config.baseUrl}/wx/yulaw/yuLawyer/${config.appid}/selectYuLawyerByIdYuLawyer`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//我要代理
	this.editAgency = async function(data, showLoading) {
		return await lib.$post({
			url: `${config.baseUrl}/wx/yulaw/yuEntrust/${config.appid}/addYuEntrust`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//创建聊天室
	this.saveChatRoom = async function(data, showLoading) {
		return await lib.$post({
			url: `${config.baseUrl}/wx/yulaw/chatRoom/${config.appid}/saveChatRoom`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//查询聊天记录
	this.findMessageByPage = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/chatRoom/${config.appid}/findMessageByPage`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//查询咨询列表
	this.findChatRoom = async function(data, showLoading) {
		return await lib.$get({
	// GET /wx/yulaw/chatRoom/findChatRoom
			url: `${config.baseUrl}/wx/yulaw/chatRoom/${config.appid}/findChatRoom`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	//律师详情  GET /wx/yulaw/yuLawyer/{appid}/seeLawyerInfo
	this.seeLawyerInfo = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/yuLawyer/${config.appid}/seeLawyerInfo`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data.data
			}
		}, showLoading)
	};
	// 律师详情 关注功能 GET /wx/yulaw/follow/{appid}/followLawer
	this.followLawer = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/follow/${config.appid}/followLawer`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data
			}
		}, showLoading)
	};
	// 律师详情 取消关注功能 GET /wx/yulaw/follow/{appid}/cancelfollow
	this.cancelfollow = async function(data, showLoading) {
		return await lib.$get({
			url: `${config.baseUrl}/wx/yulaw/follow/${config.appid}/cancelfollow`,
			data,
			responseCatch: (res, code, msg) => {
				return res.data
			}
		}, showLoading)
	};

}
HttpModule.prototype = Lib.prototype //继承Lib
export default HttpModule
